package test.exception.fatherson;

import test.exception.fatherson.exception.FatherException;
import test.exception.fatherson.exception.SonException;

/**
 * 父子异常, 父错子继
 */
public class Main {
    public static void main(String[] args) {
        try {
            throw new SonException();
        } catch (FatherException e) {
            // 会进来
            System.out.println("catch father from son");
        }

        try {
            throw new FatherException();
        } catch (SonException e) {
            // 不会进来
            System.out.println("catch son from father");
        }
    }

    /**
     * throws的时候抛父即可, 子为多余
     */
    public void smile() throws FatherException, SonException {
        System.out.println(22);
    }
}
